<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<c:set value="recruit" var="moduleName" scope="request" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>在线申请 - 经营者情况</title>
	</head>
	<body>
		<html:form action="/site/user/applyManager.do" styleId="mainForm" method="POST">
			<input type="hidden" name="method" class="method" value="save" />
			<html:hidden property="id" />
			<html:hidden property="applyBaseId" />
			<html:hidden property="position" />
			<input type="hidden" name="direction" id="direction" value="" />
			<div class="site-title">
				六、 经营者情况

			</div>
			<br />
			<table class="table-tab">
				<tr>
					<td class="td-tab<c:if test="${ applyManagerForm.position == 1 }"> cur-tab</c:if>">
						<a href="<c:url value="/site/user/applyManager.do?method=edit&applyBaseId=" /><c:out value="${ applyManagerForm.applyBaseId }" />&position=1">董事长</a>
					</td>
					<td class="td-tab<c:if test="${ applyManagerForm.position == 2 }"> cur-tab</c:if>">
						<a href="<c:url value="/site/user/applyManager.do?method=edit&applyBaseId=" /><c:out value="${ applyManagerForm.applyBaseId }" />&position=2">总经理</a>
					</td>
					<td class="td-tab<c:if test="${ applyManagerForm.position == 3 }"> cur-tab</c:if>">
						<a href="<c:url value="/site/user/applyManager.do?method=edit&applyBaseId=" /><c:out value="${ applyManagerForm.applyBaseId }" />&position=3">意向经理</a>
					</td>
					<td class="td-tab-blank"></td>
				</tr>
			</table>
			<div class="div-content">
				<table class="table-layout">
					<tr class="tr-odd">
						<td colspan="3">
							为使[上汽大众]更全面地了解未来的特许[销售商]，请填写申请公司的经营者信息表及推荐的斯柯达特许[销售商]经营者（总经理）信息表。

						</td>
					</tr>
					<tr class=tr-odd>
						<td colspan="3">
							申请公司经营者信息表：

						</td>
					</tr>
					<tr class="tr-even">
						<td>
							姓名：

							<c:if test="${ applyManagerForm.position == 1 }">
								<html:hidden property="owner" />
								<c:out value="${applyManagerForm.owner}" />
							</c:if>
							<c:if test="${ applyManagerForm.position != 1 }">
								<html:text property="owner" />
							</c:if>
						</td>
						<td>
							性别：

							<html:radio property="gender" value="1" />
							男&nbsp;&nbsp;
							<html:radio property="gender" value="2" />
							女

						</td>
						<td>
							出生日期：

							<input type="text" id="birthDay" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy年MM月dd日'})" />
							<html:hidden property="birthDay" styleId="birthDay_2" />
						</td>
					</tr>
					<tr class="tr-odd">
						<td>
							最高学历：
							<html:text property="schoolAge" />
						</td>
						<td>
							手机：

							<c:if test="${ applyManagerForm.position == 1 }">
								<html:hidden property="cellphone" />
								<c:out value="${applyManagerForm.cellphone}" />
							</c:if>
							<c:if test="${ applyManagerForm.position != 1 }">
								<html:text property="cellphone" />
							</c:if>
						</td>
						<td>
							电子邮箱：

							<html:text property="email" />
						</td>
					</tr>
					<tr class="tr-even">
						<td colspan="3">
							主要经历
						</td>
					</tr>
					<tr class="tr-odd">
						<td colspan="3">
							<table class="table-layout" id="tableExperience">
								<thead>
									<tr class="tr-even">
										<td style="width:200px;">
											时间
										</td>
										<td>
											学校或工作单位（从中学开始）
										</td>
										<td style="width:150px;">
											学位以及职务
										</td>
										<td style="width:100px;">
											操作
										</td>
									</tr>
								</thead>
								<tbody id="tbodyExperience"></tbody>
							</table>
							<div id="divExperienceFormContainer">
							</div>
							<br />
							<div class="center-opertion">
								<input type="button" value="添加" onclick="preAddExperience()" />
							</div>
						</td>
					</tr>
					<tr class="tr-even">
						<td colspan="3">
							补充说明：

						</td>
					</tr>
					<tr class="tr-odd">
						<td colspan="3">
							<html:textarea property="notes" style="width:100%" />
						</td>
					</tr>
				</table>
				<br />
				<div class="center-opertion">
					<html:submit>保存</html:submit>
					<input type="button" value="上一步" onclick="toStep(-1)" />
					<input type="button" value="下一步" onclick="toStep(1)" />
					<html:cancel>取消</html:cancel>
				</div>
			</div>
		</html:form>
		<form action="<c:url value="/site/user/experience.do?method=ajaxSave" />" method="POST" id="experienceForm" style="display:none;" target="hiddenFrame">
			<input type="hidden" name="id" />
			<input type="hidden" name="applyManagerId" value="<c:out value="${applyManagerForm.id}" />" id="currentManagerId" />
			<table class="table-layout">
				<tr class="tr-odd">
					<td style="width:200px;">
						<input type="text" name="period"  class="Wdate" style="width:85px" onclick="WdatePicker({dateFmt:'yyyy年MM月'})" />
						&nbsp;&nbsp;~&nbsp;&nbsp;
						<input type="text" name="period2"  class="Wdate" style="width:85px"  onclick="WdatePicker({dateFmt:'yyyy年MM月'})" />
					</td>
					<td>
						<input type="text" name="corp" />
					</td>
					<td style="width:150px;">
						<input type="text" name="job" />
					</td>
					<td style="width:100px;">
						<input type="submit" value="提交" />
						<input type="button" value="取消" onclick="hideExperience()" />
					</td>
				</tr>
			</table>
		</form>
		<iframe name="hiddenFrame" style="display:none;"></iframe>
		<script type="text/javascript">
function toStep(num){
	if(num > 0)
		_g("direction").value="next";
	else if(num < 0)
		_g("direction").value="last";
	_g("mainForm").submit();
}

var applyManagerIdVal = _g("currentManagerId").value;

//experience
var experienceUrl = "<c:url value='experience.do' />";
var experienceFormEl = _g("experienceForm");
var experienceAFlag=false;
function preAddExperience(){
	if(applyManagerIdVal == null || applyManagerIdVal.length < 1)
		alert("请先保存当前表单，才能添加主要经历。")
	else if(!experienceAFlag){
		showExperience();			
	}else{
		experienceFormEl.submit();		
	}
}

function resetExperience(){
	experienceFormEl.reset();
	experienceFormEl.id.value="";
}

function showExperience(){
	resetExperience();
	_g("divExperienceFormContainer").appendChild(experienceFormEl);
	experienceFormEl.style.display="";
	experienceAFlag=true;
}

function hideExperience(){
	resetExperience();
	experienceFormEl.style.display = "none";
	_g('bd').appendChild(experienceFormEl);
	experienceAFlag=false;
}

function editExperience(id){
	experienceAFlag=true;
	_ajax(experienceUrl + "?method=ajaxView&id=" + id,function(xhr){
		var experience = JSON.parse(xhr.responseText);
		if(!refreshMessage(experience)) return false;
		experience = experience.data;
		
		showExperience();
		experienceFormEl.id.value = experience.id;
		experienceFormEl.period.value = experience.period;
		experienceFormEl.period2.value = experience.period2;
		experienceFormEl.corp.value = experience.corp;
		experienceFormEl.job.value = experience.job;
	})
}

function successExperience(jsonString){
	if(!refreshMessageJsonString(jsonString)){experienceAFlag=true; return false;}
	hideExperience();
	listExperience();
	showExperience();			
}

function deleteExperience(id){
	if(confirm("确定要删除该记录吗？")) 
		_ajax(experienceUrl + "?method=ajaxErase&id="+id, function(xhr){
			var data = JSON.parse(xhr.responseText);
			if(!refreshMessage(data)) return false;
			
			listExperience();
		})
}

function listExperience(){
	if(applyManagerIdVal != null && applyManagerIdVal.length > 0)
	_ajax(experienceUrl + "?method=ajaxList&applyManagerId=" + applyManagerIdVal,function(xhr){
		var experienceList = JSON.parse(xhr.responseText);
		if(!refreshMessage(experienceList,false)) return false;
		experienceList = experienceList.data;

		var listHtml = '<table><tbody id="tbodyExperience">';
		if(experienceList && experienceList.length)
		for(var i = 0;i < experienceList.length;i++){
			listHtml += '<tr class="'+(i%2 == 0 ? 'tr-odd' : 'tr-even')+'">';
			listHtml += '<td>'+experienceList[i].period+'&nbsp;&nbsp;~&nbsp;&nbsp;'+experienceList[i].period2+'</td>';
			listHtml += '<td>'+experienceList[i].corp+'</td>';
			listHtml += '<td>'+experienceList[i].job+'</td>';
			listHtml += '<td>';
			listHtml += '<a href="javascript:void(0);" onclick="javascript:editExperience('+experienceList[i].id+');">修改</a>&nbsp;';
			listHtml += '<a href="javascript:void(0)" onclick="javascript:deleteExperience('+experienceList[i].id+');">删除</a>&nbsp;';
			listHtml += '</td>';
			listHtml += '</tr>';
		}
		listHtml += '</tbody></table>';
		equalInnerHTML(listHtml,function(tbody){
			var t = _g("tableExperience");
			var tb =  _g("tbodyExperience");
			t.removeChild(tb);
			t.appendChild(tbody);
		})
	})
}
listExperience();


		</script>
	</body>
</html>
